<%@ page language="java" pageEncoding="UTF-8" %>
<div class="sidebar collapsed menu-min" id="sidebar">
	<script type="text/javascript">
		try{ace.settings.check('sidebar' , 'fixed')}catch(e){}
		
		//创建菜单
		function createMenu(list,appendNode){
			//添加非叶子菜单
			//如果不是一级菜单,需添加<ul class='submenu'></ul>
			for(var i =0;i<list.length;i++){
				var menuObject = list[i];
				var menuId = menuObject.id;
				var menuName = menuObject.name;
				var url = menuObject.url=="/"?"#":menuObject.url;
				//判断是否为叶子节点
				if(menuObject.hasChild == true){
					appendNode.append("<li id ="+menuId+">" +
										//点击展现下级
										"<a href='#' class='dropdown-toggle'>"+
											//图标
											"<i class='icon-dashboard'></i>" +
											//显示text
											"<span class='menu-text'>"+menuName +"</span>" +
											//下级按钮
											"<b class='arrow icon-angle-down'></b>"+
									    "</a>" +
									    //下级节点添加到submenu下
									    "<ul id='"+menuId+"_ul' class='submenu' text='"+menuName+"'></ul>"+
									  "</li>");
					var children = menuObject.data;
					createMenu(children,$("#"+menuId+"_ul"));
				}else{
					//添加叶子菜单
					appendNode.append("<li id ='"+menuId+"'>"+
												"<a href='#' onclick=menuClick('"+url+"','"+menuId+"','"+menuName+"')>"+
												"<i class='icon-double-angle-right'></i>"+
												menuName+
											"</a>"+
										"</li>");
				}
			}
			
		}

		//菜单项点击事件-页面跳转,链接路径修改
		function menuClick(url,menuId,menuName){
			if(url==null || url=="null" || url==""){
				return false;
			}
			window.location.href = "${ctx}" + url+"?menuId="+menuId+"&menuName="+encodeURIComponent(menuName);
		}
		
		
		Otod.ajax({  
			url:"${ctx}/sys/menu/getAllMenu.do",
			successFn: function(data){
		        	//动态设置菜单
		        	createMenu(data,$("#navMenuRoot"));
		    }
		});
	</script>

	<div class="sidebar-shortcuts" id="sidebar-shortcuts">
		<div class="sidebar-shortcuts-large" id="sidebar-shortcuts-large">
			<button class="btn btn-success">
				<i class="icon-signal"></i>
			</button>

			<button class="btn btn-info">
				<i class="icon-pencil"></i>
			</button>

			<button class="btn btn-warning">
				<i class="icon-group"></i>
			</button>

			<button class="btn btn-danger">
				<i class="icon-cogs"></i>
			</button>
		</div>

		<div class="sidebar-shortcuts-mini" id="sidebar-shortcuts-mini">
			<span class="btn btn-success"></span>

			<span class="btn btn-info"></span>

			<span class="btn btn-warning"></span>

			<span class="btn btn-danger"></span>
		</div>
	</div><!-- #sidebar-shortcuts -->

	<!-- 菜单栏,需动态编码 -->
	<ul id="navMenuRoot" class="nav nav-list">

	<div class="sidebar-collapse" id="sidebar-collapse">
		<i class="icon-double-angle-left" data-icon1="icon-double-angle-left" data-icon2="icon-double-angle-right"></i>
	</div>

	<script type="text/javascript">
		try{ace.settings.check('sidebar' , 'collapsed menu-min')}catch(e){}
	</script>
</div>
